Skip to content

Tuple: check empty serial version 3 images strictly on deserialize - #601

Merged
proost merged 1 commit into
masterfrom
tuple-empty-check
Nov 23, 2026
Merged

proost merged 1 commit into
masterfrom
tuple-empty-check

Conversation

@leerho

@leerho leerho commented Nov 22, 2026

Copy link
Copy Markdown
Member

An empty compact tuple image was accepted whatever its other header bits held; only the seed hash check was skipped. Theta has checked empty images strictly since #543. This does the same for compact_tuple_sketch::deserialize, both the stream and the bytes overloads.

For an empty serial version 3 image, the first 8 bytes must match the form every current writer produces. The mask is 0x0000EFFFFFFFFFFF and the required value 0x00000E0001090301: preamble longs 1, serial version 3, family 9, sketch type 1, unused byte 0, and the read-only, empty and compact flags set with the big-endian and reserved bits clear. The ordered flag is ignored, since older Java wrote empty images with flags 0x0e, and so is the seed hash, which writers set to 0 or the seed hash. Serial version 1 images are unchanged. The values match apache/datasketches-java#813.

Test, "tuple sketch: deserialize checks empty images strictly", from bytes and from a stream: C++ and older Java flags, any seed hash, and serial version 1 are accepted; preamble longs 2, the legacy sketch type 5, a non-zero unused byte, a missing read-only or compact flag, and the big-endian or a reserved flag set are rejected. It fails on master. All tuple tests pass under ASan and UBSan, and all 32 tuple_int snapshots in datasketches-tck (C++, Go, Java and Rust, including the Java n0 image with flags 0x0e and the Go n0 image with seed hash 0x93cc) still read.

🤖 Generated with Claude Code

An empty compact tuple image was accepted whatever its other header
bits held. Both deserializers now require the 8-byte form every
current writer produces, as theta does: preamble longs 1, serial
version 3, family 9, sketch type 1, unused byte 0, flags read-only,
empty and compact with the reserved bits clear. The ordered flag and
the seed hash are ignored. Serial version 1 images are unchanged. The
mask and test values match Java CompactTupleSketch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leerho
leerho requested review from proost and tisonkun November 22, 2026 20:50
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 45068050363

Coverage increased (+0.01%) to 97.094%

Details

  • Coverage increased (+0.01%) from the base build.
  • Patch coverage: 17 of 17 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 17481
Covered Lines: 16973
Line Coverage: 97.09%
Coverage Strength: 1882359.89 hits per line

💛 - Coveralls

@proost proost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@proost
proost merged commit a6fa788 into master Nov 23, 2026
35 checks passed
@proost
proost deleted the tuple-empty-check branch November 23, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants